﻿<title>Mã nguồn</title>

<link href='highlight/styles/shCore.css' rel='stylesheet' type='text/css'/> 
<link href='highlight/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
<script src='highlight/scripts/shCore.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushCpp.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushCss.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushJava.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushDelphi.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushRuby.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushBash.js' type='text/javascript'></script>
<script src='highlight/scripts/shBrushPython.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushPhp.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushPerl.js' type='text/javascript'></script> 
<script src='highlight/scripts/shBrushCSharp.js' type='text/javascript'></script> 

<script language='javascript'> 
SyntaxHighlighter.config.bloggerMode = false;
SyntaxHighlighter.config.clipboardSwf = 'highlight/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>

<?php require_once("./include/db_info.inc.php");
require_once("./include/const.inc.php");
if (!isset($_GET['id'])){
	echo "Không tìm thấy mã nguồn!\n";
	require_once("oj-footer.php");
	exit(0);
}

$ok=false;
$id=strval(intval($_GET['id']));

if (isset($_POST['submit'])) {
	$sql= "update solution set comment='".htmlspecialchars($_POST['nhanxet'])."' where solution_id=".$id;
	mysql_query($sql) or die($sql);
}


$sql="SELECT * FROM `solution` WHERE `solution_id`='".$id."'";
$result=mysql_query($sql);
$row=mysql_fetch_object($result);
$slanguage=$row->language;
$sresult=$row->result;
$stime=$row->time;
$smemory=$row->memory;
$sproblem_id=$row->problem_id;
$suser_id=$row->user_id;


$ok=true;
if ($ok==true){
	//if($row->user_id!=$_SESSION['user_id'])
		//echo "<a href='mail.php?to_user=$row->user_id&title=$MSG_SUBMIT $id'>Gửi thư tới tác giả</a>";
	$brush=strtolower($language_name[$row->language]);
	if ($brush=='pascal') $brush='delphi';
	echo "<pre class=\"brush:".$brush.";\">";
	ob_start();
	echo "<pre>/**************************************************************\n";
	echo "\tBài nộp: ".$row->solution_id."\n";
	echo "\tBài toán: $sproblem_id\n\tThí sinh: $suser_id\n";
	echo "\tNgôn ngữ LT: ".$language_name[$slanguage]."\n\tKết quả: ".($OJ_OI_MODE&&(($row->result==6)||($row->result==4))?round($row->pass_rate*100,2)."%":$judge_result[$row->result])."\n";
	if ($sresult==4){
		echo "\tThời gian:".$stime." ms\n";
		echo "\tBộ nhớ:".$smemory." kb\n";
	}
	echo "****************************************************************/\n\n</pre>";
	if (isset($_SESSION['user_rights']))
	if (($_SESSION['user_rights']=="B")||($_SESSION['user_rights']=="B1")) {
		echo "Sửa nhận xét:";
		echo "<form method='post' action='?id=".$id."'>";
		echo "<input type='text' name='nhanxet' value='".$row->comment."' size='100'><input type='submit' name='submit' value='Ghi'>";
		echo "</form>";
	}
	$auth=ob_get_contents();
	ob_end_clean();
	mysql_free_result($result);
	$sql="SELECT `source` FROM `source_code` WHERE `solution_id`='".$id."'";
	$result=mysql_query($sql);
	$row=mysql_fetch_object($result);
	echo htmlspecialchars(str_replace("\n\r","\n",$row->source))."\n"."</pre>".$auth;
	mysql_free_result($result);
	
	echo "<iframe src='problemopen.php?id=".$sproblem_id."' border='0' width='800' height='300'></iframe>";
}else{
	mysql_free_result($result);
	echo "I am sorry, You could not view this code!";
}
?>

